home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00b.txt
/
000089_icon-group-sender_Mon Oct 23 12:24:29 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9NJNtE26724
for icon-group-addresses; Mon, 23 Oct 2000 12:23:55 -0700 (MST)
Message-Id: <200010231923.e9NJNtE26724@baskerville.CS.Arizona.EDU>
Delivered-To: fixup-icon-group@CS.Arizona.EDU@fixme
From: Cheyenne Wills <cheyenne_wills@uswest.net>
To: icon-group@cs.arizona.edu
Subject: Re: How to "declare" a string?
Date: Mon, 23 Oct 2000 10:59:15 +0100 (MDT)
X-Mailerorigin: http://www.fsai.fh-trier.de/~schmitzj/Xclasses/XCmail/
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1196
Icon handles datatyping differently then languages such as C, or Java.
Icon will try to convert the datatype to the apporiate type needed by the
current operation.
For example:
some_number := 1234
a_string = "this is a string"
new_number := some_number + 5 # -> 1239
new_string := a_string || "." # -> "this is a string."
another_string := "4" || "2" # -> "42"
some_fun := another_string + 3 # -> 45
more_fun := a_string || some_number # -> "this is a string1234"
Also one does not need to "declare" variables before using them. They all
have a default value of &null. What this means is that as long as the
first time the variable is used in a expression it is either "recieving a
value" or it is tested for null.
For example:
procedure main()
repeat {
if /count then count := 5 # First checks to see of varable is null
if count > 10 then break
count := count + 2
}
end
This can be rewritten as:
procedure main()
repeat {
/count := 5
(10 >= count) +:= 2
}
end
The above relies on two features of Icon, one the behavior of failure
within expressions and the fact that an expression can return (produce) a
"variable"
Cheyenne